package icu.groot.alan.servlet.department;

import com.fasterxml.jackson.databind.ObjectMapper;
import icu.groot.alan.entity.TokenEntity;
import icu.groot.alan.service.DepartmentService;
import icu.groot.alan.service.UserService;
import icu.groot.alan.service.impl.DepartmentServiceImpl;
import icu.groot.alan.service.impl.UserServiceImpl;
import icu.groot.alan.util.R;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/department/getall.do")
public class DepGetAll extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ObjectMapper objectMapper = new ObjectMapper();
        DepartmentService departmentService = new DepartmentServiceImpl();
        resp.getWriter().print(objectMapper.writeValueAsString(R.ok("查询成功").put(departmentService.getDepAll())));
    }
}
